import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../widget/my_image.dart';
class NewProduct extends StatefulWidget {

  NewProduct({this.newProduct});
  final List<dynamic> newProduct;
  @override
  _NewProductState createState() => _NewProductState();
}

class _NewProductState extends State<NewProduct> {
  @override
  Widget build(BuildContext context) {
      return Container(
        height: 350.h,
        color: Colors.white,
        padding: EdgeInsets.all(20.w),
        child: ListView.builder(
          physics: BouncingScrollPhysics(),
          scrollDirection: Axis.horizontal,
          itemBuilder: (context, index) {
            return Row(
              children: [
                InkWell(
                  onTap: (){
                    print(widget.newProduct[index]['productId']);
                    Navigator.of(context).pushNamed('/productContent',arguments: {'productId':widget.newProduct[index]['productId']});
                  },
                  child: Container(
                    decoration: BoxDecoration(
                        borderRadius:BorderRadius.circular(10),
                        border: Border.all(color:Color.fromRGBO(244, 244, 244, 1.0))
                    ),
                    child:Container(
                      height: 300.w,
                      width: 180.w,
                      child:  Column(
                        children: <Widget>[
                          Container(
                            height: 180.w,
                            width: 180.w,
                            alignment: Alignment.center,
                            child:  ClipRRect(
                              borderRadius: BorderRadius.circular(10),
                              child: MyImage(
                                  imgSrc: '${widget.newProduct[index]['image']}'
                              ),
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.only(top: 10.h),
                            height: 44.h,
                            child: Text(
                              "${widget.newProduct[index]['productName']}",
                              textAlign: TextAlign.center,
                              overflow: TextOverflow.ellipsis,
                              style: TextStyle(color: Colors.black54),
                            ),
                          ),
                          Text(   "￥${widget.newProduct[index]['price']}",style: TextStyle(
                              color:Colors.red
                          ),)
                        ],
                      ),
                    ),
                  ),
                ),
                SizedBox(
                    width:20
                )
              ],
            );
          },
          itemCount: widget.newProduct.length,
        ),
      );
  }
}
